function ccR_Warrior_Charge(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseCharge"]
	if UseAbility
	and ccrSpellCanAttack(CHARGE)
	and not ccrTargetIsWithinMeleeRange()
	then
		ccrCastAttack(CHARGE)
		return
	end
	return
end
function ccR_Warrior_Victory_Rush()
	if ccrSpellCanAttack(VICTORY_RUSH) then 
		ccrCastAttack(VICTORY_RUSH) 
		return
	end
	return
end
function ccR_Warrior_Execute()
	if ccrSpellCanAttack(EXECUTE) then
		ccrCastAttack(EXECUTE)
		return
	end
	return
end
function ccR_Warrior_Heroic_Strike()
	if ccrSpellCanAttack(HEROIC_STRIKE) then
		ccrCastAttack(HEROIC_STRIKE)
		return
	end
	return
end
function ccR_Warrior_Mortal_Strike()
	if ccrPlayerHasSpell(MORTAL_STRIKE)
	and ccrSpellCanAttack(MORTAL_STRIKE)
	then
		ccrCastAttack(MORTAL_STRIKE)
		return
	end
	return
end
function ccR_Warrior_Slam()
	if ccrPlayerHasSpell(SLAM)
	and ccrSpellCanAttack(SLAM) 
	then
		ccrCastAttack(SLAM)
		return
	end
	return
end
function ccR_Warrior_Thunder_Clap(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseThunderclap"]
	local HostileCount = ccRS["Warrior_" .. specNumber .. "_ThunderclapCount"]
	if UseAbility
	and ccrPlayerHasSpell(THUNDER_CLAP)
	and ccrSpellIsReady(THUNDER_CLAP)
	and #tblPGetMeleeEnemies >= HostileCount
	and ccrValidTarget()
	and Target:GetDistance(Player) <= 10
	then
		ccrCast(THUNDER_CLAP)
		return
	end
	return
end
function ccR_Warrior_Overpower()
	if ccrPlayerHasSpell(OVERPOWER)
	and ccrSpellCanAttack(OVERPOWER)
	then
		ccrCastAttack(OVERPOWER)
		return
	end
	return
end
function ccR_Warrior_Pummel(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UsePummel"]
	if UseAbility
	and ccrPlayerHasSpell(PUMMEL)
	and ccrSpellCanAttack(PUMMEL)
	and ccrTargetIsCastingOrChanneling()
	and ccrTargetIsInteruptable()
	then
		if ccrTargetIsChanneling() then ccrCastAttack(PUMMEL) end
		if ccrTargetIsCasting()
		and ccrTargetHasLeftOnCast(1)
		then
			ccrCastAttack(PUMMEL)
			return
		end
		return
	end
	return
end
function ccR_Warrior_Whirlwind()
	if ccrPlayerHasSpell(WHIRLWIND)
	and ccrSpellIsReady(WHIRLWIND)
	then
		ccrCast(WHIRLWIND)
		return
	end
	return
end

vLastWarriorDisarmAttempt = nil
function ccR_Warrior_Disarm(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseDisarm"]
	if UseAbility
	and ccrPlayerHasSpell(DISARM)
	and ccrSpellCanAttack(DISARM)
	and (vLastWarriorDisarmAttempt == nil or (GetTime()-vLastWarriorDisarmAttempt) > 5)
	then
		ccrCastAttack(DISARM)
		vLastWarriorDisarmAttempt = GetTime()
		return
	end
	return
end
function ccR_Warrior_Battle_Shout()
	if ccrPlayerHasSpell(BATTLE_SHOUT)
	and ccrSpellIsReady(BATTLE_SHOUT)
	and ccrPlayerRage() <= 80
	then
		ccrCast(BATTLE_SHOUT)
		return
	end
	return
end
function ccR_Warrior_Cleave_or_Heroic_Strike(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseCleave"]
	if UseAbility
	and ccrPlayerHasSpell(CLEAVE)
	and #tblPGetMeleeEnemies >= 2
	then
		-- Cleave
		if ccrSpellCanAttack(CLEAVE) then
			ccrCastAttack(CLEAVE)
			return
		end
		return
	else
		-- Heroic Strike
		ccR_Warrior_Heroic_Strike()
		return
	end
	return
end
function ccR_Warrior_ShieldWall()
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseShieldWall"]
	local Health = ccRS["Warrior_" .. specNumber .. "_ShieldWallHP"]
	if UseAbility
	and ccrPlayerHealth() <= Health
	and ccrPlayerHasSpell(SHIELD_WALL)
	and ccrSpellIsReady(SHIELD_WALL)
	then
		ccrCast(SHIELD_WALL)
		return
	end
	return
end
function ccR_Warrior_Berserker_Rage()
	if ccrPlayerHasSpell(BERSERKER_RAGE)
	and ccrSpellIsReady(BERSERKER_RAGE)
	and ccrPlayerRage() <= 90
	then
		ccrCast(BERSERKER_RAGE)
		return
	end
	return
end
function ccR_Warrior_Die_By_The_Sword()
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseDieByTheSWord"]
	local Health = ccRS["Warrior_" .. specNumber .. "_DieByTheSwordHP"]
	if UseAbility
	and ccrPlayerHealth() <= Health
	and ccrPlayerHasSpell(DIE_BY_THE_SWORD)
	and ccrSpellIsReady(DIE_BY_THE_SWORD)
	then
		ccrCast(DIE_BY_THE_SWORD)
		return
	end
	return
end
function ccR_Warrior_Sweeping_Strikes()
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseSweepingStrikes"]
	if UseAbility
	and ccrPlayerHasSpell(SWEEPING_STRIKES)
	and not ccrPlayerHasBuff(SWEEPING_STRIKES)
	and ccrSpellIsReady(SWEEPING_STRIKES)
	and #tblPGetMeleeEnemies >= 2
	then
		ccrCast(SWEEPING_STRIKES)
		return
	end
	return
end
function ccR_Warrior_Recklessness(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseRecklessness"]
	if UseAbility
	and ccrPlayerHasSpell(RECKLESSNESS)
	and ccrSpellIsReady(RECKLESSNESS)
	and ccrTargetIsWithinMeleeRange()
	and (ccrTargetIsBoss() or ccrTargetIsRare())
	then
		ccrCast(RECKLESSNESS)
		return
	end
end
function ccR_Warrior_Colossus_Smash()
	if ccrPlayerHasSpell(COLOSSUS_SMASH)
	and ccrSpellCanAttack(COLOSSUS_SMASH)
	then
		ccrCastAttack(COLOSSUS_SMASH)
		return
	end
	return
end
function ccR_Warrior_Rallying_Cry()
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseRallyingCry"]
	local Health = ccRS["Warrior_" .. specNumber .. "_RallyingCryHP"]
	if UseAbility
	and ccrSpellIsReady(RALLYING_CRY)
	and ccrPlayerHasSpell(RALLYING_CRY)
	and ccrPlayerHealth() <= Health
	then
		ccrCast(RALLYING_CRY)
		return
	end
	return
end
function ccR_Warrior_Skull_Banner(specNumber)
	if specNumber == nil then specNumber = ccrPlayerSpec() end
	local UseAbility = ccRS["Warrior_" .. specNumber .. "_UseSkullBanner"]
	if UseAbility
	and ccrPlayerHasSpell(SKULL_BANNER)
	and ccrSpellIsReady(SKULL_BANNER)
	and ccrTargetIsWithinMeleeRange()
	and (ccrTargetIsBoss() or ccrTargetIsRare())
	then
		ccrCast(SKULL_BANNER)
		return
	end
end

ccR_Last_Spell_Reflection_Check = 0.1
function ccR_Warrior_Spell_Reflection(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseAbility = ccRS["Warrior_" .. specNumber .. "_UseSpellReflection"]
	if vUseAbility
	and ccrPlayerHasSpell(SPELL_REFLECTION)
	and ccrSpellIsReady(SPELL_REFLECTION)
	and (GetTime()-ccR_Last_Spell_Reflection_Check > 1)
	then
		local x
		if # tblPGetNearbyEnemies > 0 then
			for x = 0, # tblPGetNearbyEnemies do
				local obj = tblPGetNearbyEnemies[x]
				if obj
				and obj:Exists()
				and (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName())
				and ccrUnitIsCastingOrChanneling(obj)
				then
					if ccrUnitIsCasting(obj)
					and ccrUnitHasLeftOnCast(obj, 1)
					then
						ccrCast(SPELL_REFLECTION)
						return
					end
					if ccrUnitIsChanneling(obj) then
						ccrCast(SPELL_REFLECTION)
						return
					end									
				end
			end
		end	
		ccR_Last_Spell_Reflection_Check = GetTime()
	end
end
--[[
	PROTECTION
]]
function ccR_Warrior_Shield_Slam()
	if ccrPlayerHasSpell(SHIELD_SLAM)
	and ccrSpellCanAttack(SHIELD_SLAM)
	then
		ccrCastAttack(SHIELD_SLAM)
		return
	end
	return
end
function ccR_Warrior_Shield_Block()
	if ccrPlayerHasSpell(SHIELD_BLOCK)
	and ccrSpellIsReady(SHIELD_BLOCK)
	and not ccrPlayerHasBuff(SHIELD_BLOCK)
	then
		ccrCast(SHIELD_BLOCK)
		return
	end
end
function ccR_Warrior_Revenge()
	if ccrPlayerHasSpell(REVENGE)
	and ccrSpellCanAttack(REVENGE)
	then
		ccrCastAttack(REVENGE)
		return
	end
	return
end
function ccR_Warrior_Protection_Thunder_Clap()
	if ccrPlayerHasSpell(THUNDER_CLAP)
	and ccrSpellIsReady(THUNDER_CLAP)
	and not ccrPlayerHasBuff(CHARGE)
	then
		ccrCast(THUNDER_CLAP)
		return
	end
	return
end
function ccR_Warrior_Devastate()
	if ccrPlayerHasSpell(DEVASTATE)
	and ccrSpellCanAttack(DEVASTATE)
	then
		ccrCastAttack(DEVASTATE)
		return
	end
	return
end
function ccR_Warrior_Last_Stand()
	if ccrPlayerHasSpell(LAST_STAND)
	and ccrSpellIsReady(LAST_STAND)
	and ccrPlayerHealth() <= 30
	then
		ccrCast(LAST_STAND)
		return
	end
	return
end
function ccR_Warrior_Protection_Cleave()
	if ccrPlayerHasSpell(CLEAVE)
	and ccrSpellCanAttack(CLEAVE)
	then
		ccrCastAttack(CLEAVE)
		return
	end
	return
end
function ccR_Warrior_Protection_Shout()
	if not ccrPlayerHasSpell(COMMANDING_SHOUT) then
		if ccrPlayerHasSpell(BATTLE_SHOUT)
		and ccrSpellIsReady(BATTLE_SHOUT)
		and ccrPlayerRage() <= 80
		then
			ccrCast(BATTLE_SHOUT)
			return
		end
		return	
	else
		if ccrSpellIsReady(COMMANDING_SHOUT)
		and ccrPlayerRage() <= 80
		then
			ccrCast(COMMANDING_SHOUT)
			return
		end
		return
	end
	return
end
function ccR_Warrior_Protection_Demoralizing_Shout()
	if ccrPlayerHasSpell(DEMORALIZING_SHOUT)
	and ccrSpellIsReady(DEMORALIZING_SHOUT)
	then
		ccrCast(DEMORALIZING_SHOUT)
		return
	end
	return
end